include("shared.lua")

local isTouching = false
local timerCreated = false

ENT.RenderGroup = RENDERGROUP_BOTH

function ENT:Initialize()
	
	self:SetRenderMode( RENDERMODE_NORMAL )
	self:SetColor(Color(17, 45, 157, 255))
end

function ENT:DrawTranslucent()
	self:Draw()
end
 

function ENT:Draw()
    self.Entity:DrawModel()
end

function ENT:OnRemove()
end

function ENT:Think()
end

function ENT:DrawEntityOutline( size )
        return false;
end

function Hider_EnableTransparency( Blox )
        Blox:SetNotSolid( true )
		Blox:SetRenderMode(RENDERMODE_TRANSALPHA)
		Blox:SetColor(Color(17, 45, 157, 150))
        timer.Simple(1, function()
			Hider_DisableTransparency(Blox)
		end)
end

function Hider_DisableTransparency( Blox )
        Blox:SetNotSolid( false )
		Blox:SetRenderMode(RENDERMODE_NORMAL)
		col = Color(17, 45, 157, 255)
        timerCreated = false
end


function ENT:SpawnFunction( ply, tr ) 
        if ( !tr.Hit ) then return end 

        local SpawnPos = tr.HitPos + tr.HitNormal * 16
        local ent = ents.Create( self.Classname )

        ent:SetPos( SpawnPos ) 
        ent:Spawn() 
        ent:Activate() 

        return ent 
end 

function ENT:StartTouch( ent )
        if ( IsValid(ent) and ent:IsPlayer() ) then
                isTouching = true
                if not timerCreated then
					local block = self.Entity
				
					timer.Simple(.25, function()
						EnableTransparency(block)
						timerCreated = true
					end)
				end
        end
end
